package com.aspose.cells;

import java.util.ArrayList;

class zbqg {
   private int a;
   private ArrayList b;
   private String[] c;
   private ArrayList d;
   private String e;

   zbqg() {
      this.b = new ArrayList();
   }

   zbqg(int var1) {
      this.a = var1;
      this.b = new ArrayList();
   }

   int a() {
      return this.a;
   }

   void a(int var1) {
      this.a = var1;
   }

   ArrayList b() {
      return this.b;
   }

   void a(ArrayList var1) {
      this.b = var1;
   }

   int a(WorksheetCollection var1, String var2) {
      int var3 = -1;
      boolean var4 = false;

      for(int var5 = 0; var5 < this.b().size(); ++var5) {
         zuk var6 = (zuk)this.b().get(var5);
         if (com.aspose.cells.b.a.zv.b(var6.e().toUpperCase(), var2.toUpperCase())) {
            var3 = var5 + 1;
            var4 = true;
            break;
         }
      }

      if (!var4) {
         zuk var7 = new zuk(this);
         com.aspose.cells.b.a.a.ze.a(this.b(), (Object)var7);
         var3 = this.b().size();
      }

      return var3;
   }

   void a(String var1) {
      if (this.c == null) {
         this.c = new String[]{var1};
      } else {
         String[] var2 = new String[this.c.length + 1];

         for(int var3 = 0; var3 < this.c.length; ++var3) {
            var2[var3] = this.c[var3];
         }

         var2[var2.length - 1] = var1;
         this.c = var2;
      }
   }

   String[] c() {
      return this.c;
   }

   void a(String[] var1) {
      this.c = var1;
   }

   int b(String var1) {
      if (this.c != null && this.c.length != 0) {
         for(int var2 = 0; var2 < this.c.length; ++var2) {
            if (com.aspose.cells.b.a.zv.a(this.c[var2], var1, true) == 0) {
               return var2;
            }
         }

         return -1;
      } else {
         return -1;
      }
   }

   ArrayList d() {
      return this.d;
   }

   void b(ArrayList var1) {
      this.d = var1;
   }

   zut b(int var1) {
      if (this.d == null) {
         this.d = new ArrayList();
      }

      if (var1 >= this.d.size()) {
         for(int var2 = this.d.size(); var2 < var1 + 1; ++var2) {
            com.aspose.cells.b.a.a.ze.a(this.d, (Object)null);
         }
      }

      zut var3 = (zut)this.d.get(var1);
      if (var3 == null) {
         var3 = new zut();
         this.d.set(var1, var3);
      }

      return var3;
   }

   zut c(int var1) {
      if (this.d == null) {
         return null;
      } else {
         return var1 >= this.d.size() ? null : (zut)this.d.get(var1);
      }
   }

   zut c(String var1) {
      var1 = var1.toUpperCase();
      if (this.c != null) {
         for(int var2 = 0; var2 < this.c.length; ++var2) {
            if (com.aspose.cells.b.a.zv.b(this.c[var2].toUpperCase(), var1)) {
               return this.c(var2);
            }
         }
      }

      return null;
   }

   boolean e() {
      return this.a == 1;
   }

   boolean f() {
      return this.a == 2;
   }

   boolean g() {
      return this.k().indexOf("\\AddIns\\") != -1;
   }

   boolean h() {
      return this.a == 0;
   }

   void a(zbqg var1) {
      this.a = var1.a;
      this.e = var1.e;
      int var2;
      if (var1.c != null) {
         this.c = new String[var1.c.length];

         for(var2 = 0; var2 < var1.c.length; ++var2) {
            this.c[var2] = var1.c[var2];
         }
      }

      if (var1.b != null && var1.b.size() > 0) {
         for(var2 = 0; var2 < var1.b.size(); ++var2) {
            zuk var3 = (zuk)var1.b.get(var2);
            zuk var4 = new zuk(this);
            var4.a(var3);
            com.aspose.cells.b.a.a.ze.a(this.b, (Object)var4);
         }
      }

      if (var1.d != null) {
         this.d = new ArrayList();

         for(var2 = 0; var2 < var1.d.size(); ++var2) {
            zut var5 = (zut)var1.d.get(var2);
            if (var5 == null) {
               com.aspose.cells.b.a.a.ze.a(this.d, (Object)null);
            } else {
               zut var6 = new zut();
               var6.a(var5);
               com.aspose.cells.b.a.a.ze.a(this.d, (Object)var6);
            }
         }
      }

   }

   String i() {
      return this.e;
   }

   void d(String var1) {
      this.e = var1;
   }

   String j() {
      return this.e != null && !"".equals(this.e) ? f(this.e) : null;
   }

   static String a(String var0, Workbook var1) {
      if (var0 != null && !"".equals(var0)) {
         StringBuilder var3 = new StringBuilder();
         char[] var4 = var0.toCharArray();
         switch(var4[0]) {
         case '\u0000':
         case '\u0002':
            return "";
         case '\u0001':
            int var5 = 1;

            for(; var5 < var4.length; ++var5) {
               switch(var4[var5]) {
               case '\u0001':
                  if (var4[var5 + 1] == '@') {
                     ++var5;
                     var3.append("\\\\");
                  } else {
                     var3.append(var4[var5 + 1]);
                     ++var5;
                     var3.append(":\\");
                  }
                  break;
               case '\u0002':
                  if (var1.h() != null) {
                     var3.append(com.aspose.cells.a.c.zt.a(var1.h()));
                  } else {
                     var3.append("C:\\");
                  }
                  break;
               case '\u0003':
                  if (var1.h() != null && var3.length() == 0) {
                     var3.append(var1.h());
                     break;
                  }

                  var3.append("\\");
                  break;
               case '\u0004':
                  if (var1.h() != null) {
                     int var6 = var1.h().lastIndexOf(92);
                     if (var6 != -1 && var6 != var1.h().length() - 1) {
                        var3.append(var1.h().substring(0, 0 + var6 + 1));
                        break;
                     }

                     var3.append(var1.h());
                     break;
                  }

                  var3.append("../");
                  break;
               case '\u0005':
                  if (var5 == 1) {
                     return var0.substring(var5 + 2);
                  }

                  var3.append(var4[var5]);
                  break;
               case '\u0006':
                  if (CellsHelper.getStartupPath() != null) {
                     var3.append(CellsHelper.getStartupPath());
                  }
                  break;
               case '\u0007':
                  if (CellsHelper.getLibraryPath() != null) {
                     var3.append(CellsHelper.getLibraryPath());
                  }
                  break;
               case '\b':
                  if (CellsHelper.getAltStartPath() != null) {
                     var3.append(CellsHelper.getAltStartPath());
                  }
                  break;
               case '\'':
                  if (var5 + 1 < var4.length && var4[var5 + 1] != '\'') {
                     var3.append("''");
                  }
                  break;
               default:
                  if (var5 == 1 && var1.h() != null) {
                     var3.append(var1.h());
                  }

                  var3.append(var4[var5]);
               }
            }

            return com.aspose.cells.b.a.zr.a(var3);
         default:
            if (var1.h() != null) {
               var3.append(var1.h());
            }

            var3.append(var0);
            return com.aspose.cells.b.a.zr.a(var3);
         }
      } else {
         return null;
      }
   }

   String a(Workbook var1) {
      return a(this.e, var1);
   }

   void a(String[] var1, String[] var2) {
      var2[0] = var1[0] = "";
      if (this.a == 3 || this.a == 4) {
         String[] var3 = com.aspose.cells.b.a.zv.d(this.e, '\u0003');
         var1[0] = var3[0];
         var2[0] = var3[1];
      }

   }

   void a(String var1, String var2) {
      this.e = var1 + '\u0003' + var2;
   }

   void b(String[] var1, String[] var2) {
      var1[0] = var2[0] = "";
      if (this.a == 3 || this.a == 4) {
         String[] var3 = com.aspose.cells.b.a.zv.d(this.e, '\u0003');
         var1[0] = var3[0];
         var2[0] = var3[1];
         if (var2[0] != null && var2[0].length() > 2) {
            if (var2[0].charAt(1) == ':') {
               var2[0] = "file:///" + var2[0];
            } else if (var2[0].charAt(0) == '\\' && var2[0].charAt(1) == '\\') {
               var2[0] = "file:///" + var2[0];
            }
         }
      }

   }

   void b(String var1, String var2) {
      if (var2.startsWith("file:///")) {
         var2 = var2.substring(8);
      }

      this.e = var1 + '\u0003' + var2;
   }

   void a(String var1, String[] var2, int var3) {
      if (var1 == null || "".equals(var1)) {
         this.e = null;
      }

      this.e = a(var1, var3);
      this.c = var2;
   }

   String k() {
      if (this.a != 3 && this.a != 4) {
         return f(this.e);
      } else {
         String[] var1 = com.aspose.cells.b.a.zv.d(this.e, '\u0003');
         return var1[1];
      }
   }

   String l() {
      String var1 = null;
      if (this.a != 3 && this.a != 4) {
         var1 = f(this.e);
      } else {
         String[] var2 = com.aspose.cells.b.a.zv.d(this.e, '\u0003');
         var1 = var2[1];
      }

      if (var1 != null && var1.length() > 2) {
         if (var1.charAt(1) == ':') {
            var1 = "file:///" + var1;
         } else if (var1.charAt(0) == '\\' && var1.charAt(1) == '\\') {
            var1 = "file:///" + var1;
         }
      }

      return var1;
   }

   void e(String var1) {
      String var2 = var1;
      if (var1.startsWith("file:///")) {
         var2 = var1.substring(8);
      }

      this.e = a(var2, 0);
   }

   static String a(String var0, int var1) {
      var0 = var0.replace('/', '\\');
      if (var1 == 0 && var0.indexOf(92) == -1) {
         return var0;
      } else {
         char[] var2 = var0.toCharArray();
         StringBuilder var3 = new StringBuilder();
         var3.append('\u0001');
         int var4 = 0;
         boolean var5 = false;
         if (var2.length >= 2) {
            if (var2[0] == '\\') {
               if (var2[1] == '\\') {
                  var5 = true;
                  var3.append(d(1));
                  var3.append('@');
                  var4 = 2;
               } else {
                  var3.append(d(2));
                  var4 = 1;
               }
            } else if (var2[0] == '.' && var2[1] == '.') {
               var3.append(d(4));
               var4 = 3;
            } else if (var2[1] == ':') {
               var5 = true;
               var3.append(d(1));
               var3.append(var2[0]);
               var4 = 3;
            }
         }

         if (!var5) {
            switch(var1) {
            case 6:
            case 7:
            case 8:
               if (var3.length() < 2) {
                  var3.append(d(var1));
               } else {
                  var3.insert(1, d(var1));
               }
            }
         }

         for(; var4 < var2.length; ++var4) {
            switch(var2[var4]) {
            case '\\':
               var3.append(d(3));
               break;
            default:
               var3.append(var2[var4]);
            }
         }

         return com.aspose.cells.b.a.zr.a(var3);
      }
   }

   static String f(String var0) {
      if (var0 != null && !"".equals(var0)) {
         StringBuilder var1 = new StringBuilder();
         char[] var2 = var0.toCharArray();
         switch(var2[0]) {
         case '\u0000':
         case '\u0002':
            return "";
         case '\u0001':
            for(int var3 = 1; var3 < var2.length; ++var3) {
               switch(var2[var3]) {
               case '\u0001':
                  if (var2[var3 + 1] == '@') {
                     ++var3;
                     var1.append("\\\\");
                  } else {
                     var1.append(var2[var3 + 1]);
                     ++var3;
                     var1.append(":\\");
                  }
                  break;
               case '\u0002':
                  var1.append("\\");
                  break;
               case '\u0003':
                  var1.append("\\");
                  break;
               case '\u0004':
                  var1.append("../");
                  break;
               case '\u0005':
                  ++var3;
               case '\u0006':
               case '\u0007':
               case '\b':
                  break;
               default:
                  var1.append(var2[var3]);
               }
            }

            return com.aspose.cells.b.a.zr.a(var1);
         default:
            return var0;
         }
      } else {
         return "";
      }
   }

   static char d(int var0) {
      return (char)var0;
   }
}
